<template>
  <div class="content">
    <navBar :navBar="navBar"></navBar>
    <div class="list">
      <van-list
        v-model="loading"
        :finished="finished"
        :finished-text="$t('没有更多了')"
        @load="onLoad"
      >
        <div class="onebox" v-for="(item, index) in list" :key="index">
          <div class="con">
            <div class="name">{{ $t(item.remark) }}</div>
            <div class="time">{{ getdate(item.addtime) }}</div>
          </div>
          <div :class="item.type == 1 ? 'zhang' : 'die'">
            {{ item.type == 1 ? "+" : "" }}{{ item.money }} {{item.bi_name}}
          </div>
        </div>
      </van-list>
    </div>
  </div>
</template>

<script>
import navBar from "@/components/navBar.vue";
export default {
  name: "recharge",
  components: { navBar },
  data() {
    return {
      navBar: {
        back: true,
        title: this.$t("账变记录"),
        close: false,
        btn: "",
      },
      list: [],
      page: 0,
      loading: false,
      finished: false,
	  
	  totalElements: 0,
    };
  },

  mounted() {},

  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    //时间戳转日期
    getdate(nS) {
	  
	  //var offset = 	new Date().getTimezoneOffset() / 60 + 1;
	  //console.log(offset);
      //var date = new Date(nS*1000 + offset * 3600  * 1000);  //时间戳为10位需*1000，时间戳为13位的话不需乘1000
	  var date = new Date(nS*1000);
	
      var year = date.getFullYear(),
      		  month = ("0" + (date.getMonth() + 1)).slice(-2),
      		  sdate = ("0" + date.getDate()).slice(-2),
      		  hour = ("0" + date.getHours()).slice(-2),
      		  minute = ("0" + date.getMinutes()).slice(-2),
      		  second = ("0" + date.getSeconds()).slice(-2);
      // 拼接
      var result = year + "-"+ month +"-"+ sdate +" "+ hour +":"+ minute +":" + second;
      // 返回
      return result;
    },
    onLoad() {
      var that = this;
      $postAxios(
        api.getUserAccountList,
        {
          page: this.page,
          rows: 10,
        },
        (res) => {
          if (res.code == 0) {
			this.totalElements = res.count;
            if (res.data.length) {
              if (that.page === 0) {
                that.list = res.data;
               
              } else {
                that.list = that.list.concat(res.data);
              }
              that.loading = false;
              that.page++;
            } else {
              that.finished = true;
            }
          }
        }
      );
    },
  },
};
</script>

<style lang="scss" scoped>
.content {
  width: 100%;
  min-height: 100vh;
  height: auto;
  background-color: #21212b;
  .emptyBox {
    width: 100%;
    height: 40px;
  }
  .list {
    width: 100%;
    position: absolute;
    left: 0;
    top: 40px;
    bottom: 0;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background-color: #21212b;
    .onebox {
      padding: 10px;
      box-sizing: border-box;
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-bottom: solid 1px #000;
      .con {
        .name {
          font-size: 16px;
          color: #fff;
          padding: 10px 0;
        }
        .time {
          font-size: 12px;
          color: #fff;
        }
      }

      .zhang {
        font-size: 14px;
        color: #cd4e65;
      }
      .die {
        color: #1cad90;
        font-size: 14px;
      }
    }
  }
}
</style>
